home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9004 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: free() wont free
  5. Date: 7 Mar 1996 16:48:46 GMT
  6. Organization: Borland International
  7. Message-ID: <4hn41e$2dh@druid.borland.com>
  8. References: <31398D95.5701DCB4@halo.tau.ac.il>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <31398D95.5701DCB4@halo.tau.ac.il>, besther@halo.tau.ac.il says...
  15. >
  16. >Hi,
  17. >i got a problem with memory allocation, or rather deallocation.
  18. >i malloc() a linked list inside some function, use it i some other
  19. >functions and try to free() it using another funtion (all of this is in
  20. >borlnd c++ 3.1).
  21. >problem is free() doesn't free any of the memory. fter a few rounds (of
  22. >creating a few lists) i just ruun out of memory (malloc return a NULL).
  23. >i check the free memory with coreleft() and it's the same before and
  24. >after the call(s) to free(). i tried a simple program which allocates
  25. >memory using mlloc and then frees it using free() and the memmory was
  26. >freed (it showed in coreleft()) although i don't think it should have
  27. >been returned to the system, only to the free list but that doesnn't
  28. >realy matter.
  29. >
  30. >How do i REALY fre the memory so i can use it again?
  31.  
  32.     First, read the documentation for coreleft(). Calling it won't 
  33. necessarily tell you whether a particular call to free() did anything.
  34.     Second, assume that free() does its job. The problem is not that 
  35. free() doesn't work, but that your program allocates memory that it never 
  36. frees. Track through all of the memory allocations that it does, find out 
  37. where the leaks are, and fix them. If you can't find the leaks you aren't 
  38. looking hard enough.
  39.  
  40.